<?php

function __autoload($class_name) 
{
    require_once "$class_name.class.php";
}


$parrainage=new SplObjectStorage(); 
$p2=new Profil('Parrain');
for ($i=1;$i<3;$i++) {
	$p=$p2;
	$p2=new Profil("Parrainnee-".$i);	
	$parrainage[$p]=$p2;
}

echo "\n\nNb element: ".count($parrainage)."\n";
$parrainage->rewind();
while($parrainage->valid()) {
    $index  = $parrainage->key();
    $object = $parrainage->current(); // similar to current($s)
    $data   = $parrainage->getInfo();

	echo "######################################\n";
	echo "Index: $index\n";
	echo "Cle: $object\n";
	echo "Valeur: $data\n";
    $parrainage->next();
}

echo "\n######################################\n";
print_r($parrainage);
echo "######################################\n";
?>
